#!/usr/bin/env bash
import core/setup-ssh
function setup(){
n="$(color_li 0)"
d="$(color_li 1)"
f="${cOff}"
prompt_choose_function \
"# bent setup [command] " \
"run setup git" "git" "Configure your git environment" \
"run setup ssh" "ssh" "Create an SSH key & upload it to your git host" \
;
}
function setup_help(){
run setup
}
setup_git(){
header "UNPOLISHED FEATURE"
msg " This feature is imperect, but it should work"
msg_instruct "[ctrl-c] to exit"
# Configure git user
gitUser=`git config --global user.name`
default=""
if [[ -n $gitUser ]]; then
default="([blank]-use '${gitUser}')"
fi
prompt_quit "Enter git user name. ${default}:" gitUser -e \
&& return;
if [[ $gitUser != "" ]]; then
cleanGitUser=$(echo "${gitUser}" | sed 's/[^0-9a-zA-Z\-\_\.]//g')
if [[ $gitUser != $cleanGitUser ]]; then
msg_mistake "You can only use numbers, letters, hyphens (-), and underscore (_), period (.). Run bent setup again";
return;
fi
git config --global user.name $gitUser
fi
gitUser=`git config --global user.name`
# Configure git email
gitEmail=`git config --global user.email`
default=""
if [[ -n $gitEmail ]]; then
default="([blank]-use '${gitEmail}')"
fi
prompt_quit "Enter public email. ${default}:" gitEmail -e \
&& return
if [[ $gitEmail != "" ]]; then
cleanGitEmail=$(echo ${gitEmail} | sed 's/[^0-9a-zA-Z\-\_\@\.\+]//g')
if [[ $gitEmail != $cleanGitEmail ]]; then
msg "You can only use numbers, letters, hyphens (-), underscore (_), arroba (@), period (.), plus (+). Try again";
return;
fi
git config --global user.email $gitEmail
fi
# gitEmail=`git config --global user.email`
msg_status "Done"
}